home *** CD-ROM | disk | FTP | other *** search
/ DarkBASIC - The Ultimate 3D Game Creator / PCactive 8 CD1 - DarkBasic.iso / SOFTWARE / DEMOS / DarkForge2000 / minitron / minitron.DBA next >
Encoding:
Text File  |  2000-05-28  |  1.7 KB  |  47 lines

  1. ` -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  2. `               MiniTron
  3. ` -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  4. ` By Rich Davey (rich@fatal-design.com)
  5. ` -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  6. ` Music listened  to while  coding this
  7. ` Interstellar Harmony Volume 1
  8. ` -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  9. ` Note:
  10. `
  11. ` The objective was to write a complete
  12. ` game in 20 lines of code or less. I
  13. ` did it in 19. Includes 2 players and
  14. ` rudimentary Artificial Intelligence!
  15.  
  16. sync rate 0 : sync on : hide mouse : dim grid(639,479) : ink rgb(255,255,255),0
  17.  
  18. for a=0 to 639 : grid(a,0)=1 : grid(a,479)=1 : dot a,0 : dot a,479 : next a
  19. for a=0 to 479 : grid(0,a)=1 : grid(639,a)=1 : dot 0,a : dot 639,a : next a
  20.  
  21. x=50 : y=100 : d=2 : keycheck=timer() : ex=600 : ey=100 : ed=4 : c=0
  22.  
  23. do
  24.  
  25.     if d=1 : dec y : endif : if d=2 : inc x : endif : if d=3 : inc y : endif : if d=4 : dec x : endif
  26.     if ed=1 : dec ey : endif : if ed=2 : inc ex : endif : if ed=3 : inc ey : endif : if ed=4 : dec ex : endif
  27.  
  28.     if grid(x,y)=1 then set cursor 0,0 : print "YOU DIE" : wait key : end
  29.     if grid(ex,ey)=1 then set cursor 0,0 : print "YOU WIN" : wait key : end
  30.  
  31.     ink rgb(255,0,0),0 : dot x,y : ink rgb(0,255,0),0 : dot ex,ey : grid(x,y)=1 : grid(ex,ey)=1
  32.  
  33.     if timer()>keycheck+125 : if leftkey()=1 : dec d : keycheck=timer() : if d=0 : d=4 : endif: endif : if rightkey()=1 : inc d : keycheck=timer() : if d=5 then d=1 : endif : endif
  34.  
  35.     if ed=1 : if grid(ex,ey-1)=1 then c=1 : endif
  36.     if ed=2 : if grid(ex+1,ey)=1 then c=1 : endif
  37.     if ed=3 : if grid(ex,ey+1)=1 then c=1 : endif
  38.     if ed=4 : if grid(ex-1,ey)=1 then c=1 : endif
  39.  
  40.     if c=1 : inc ed : c=0 : if ed=5 then ed=1
  41.     if ed=0 then ed=4 : endif
  42.  
  43.     sync
  44.  
  45. loop
  46.  
  47.